using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Seesmic.Sdp.Utils;
using PTiRouZ.Net.SilverLight.Api.HelloTipi;
using System.Collections.ObjectModel;

namespace Seesmic.HelloTipi.Controls
{
    public partial class NotificationItemTemplate : UserControl
    {
        private HelloTipiTimeLineItem _itemData;

        // Methods
        public NotificationItemTemplate()
        {
            InitializeComponent();
        }

        private void Username_Click(object sender, RoutedEventArgs e)
        {
            _itemData = (HelloTipiTimeLineItem)base.DataContext;

            apitxt api = new apitxt(_itemData.Account.Username, _itemData.Account.Password, "Seesmic Desktop 2");

            api.FamilyFriendsCompleted += new FamilyFriendsEventHandler(api_FamilyFriendsCompleted);

            api.FamilyFriends(_itemData.Site.name);
        }

        void api_FamilyFriendsCompleted(object sender, FamilyFriendsEventArgs e)
        {
            family_friends contact = (from family_friends c in (ObservableCollection<family_friends>)e.result
                                      where c.id == _itemData.User.id
                                      select c).FirstOrDefault();

            HelloTipiUserProfile _profile = new HelloTipiUserProfile() { ItemData = _itemData, Contact = contact };

            HelloTipiPlugin.ShellService.ShowProfile(_profile);
        }
    }
}

